package com.pubinfo.passbook.common.service.engine.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pubinfo.passbook.common.entity.TEngineComputeRule;
import com.pubinfo.passbook.common.entity.TEnginePlaceholderEquation;
import com.pubinfo.passbook.common.mapper.TEngineComputeRuleMapper;
import com.pubinfo.passbook.common.model.dto.engine.EngineEquationParam;
import com.pubinfo.passbook.common.model.dto.engine.EngineRuleParam;
import com.pubinfo.passbook.common.service.engine.EngineComputeRuleService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author zhouch
 * @date 2021/12/17 11:23
 */
@Service
public class EngineComputeRuleServiceImpl extends ServiceImpl<TEngineComputeRuleMapper, TEngineComputeRule> implements EngineComputeRuleService {
    @Override
    public IPage<TEngineComputeRule> page(EngineRuleParam param) {
        Page<TEngineComputeRule> pager = param.getPage();
        return new LambdaQueryChainWrapper<>(baseMapper)
                .like(StringUtils.isNotBlank(param.getKeyword()), TEngineComputeRule::getName, param.getKeyword())
                .page(pager);
    }
}
